package cn.sonui.onlinechat.utils;

public class Permission {
    private Integer value;

    public Integer getValue() {
        return this.value;
    }
    public Permission(Integer value) {
        this.value = value;
    }

    public static final Permission PermissionSuperAdmin = new Permission(0xFFFFFFFF);
    public static final Permission PermissionUser = new Permission(0x00000003);

    public void setValue(Integer value) {
        this.value = value;
    }
    public void ban() {
        this.value = this.value & 0xFFFFFFFE;//最低位设为0
    }

    public void createGroup(boolean can) {
        this.value |= (can ? 1 : 0) << 2;
    }

    public boolean canCreateGroup() {
        return (this.value & (1 << 2)) != 0;
    }
    public void removeMember(boolean can) {
        this.value |= (can ? 1 : 0) << 3;
    }

    public boolean canRemoveMember() {
        return (this.value & (1 << 3)) != 0;
    }

    public void setGroupName(boolean can) {
        this.value |= (can ? 1 : 0) << 4;
    }

    public boolean canSetGroupName() {
        return (this.value & (1 << 4)) != 0;
    }

    public void memberJoin(boolean can) {
        this.value |= (can ? 1 : 0) << 5;
    }

    public boolean canMemberJoin() {
        return (this.value & (1 << 5)) != 0;
    }

    public void setMemberTitle(boolean can) {
        this.value |= (can ? 1 : 0) << 6;
    }

    public boolean canSetMemberTitle() {
        return (this.value & (1 << 6)) != 0;
    }

    public void setGroupInfo(boolean can) {
        this.value |= (can ? 1 : 0) << 7;
    }

    public boolean canSetGroupInfo() {
        return (this.value & (1 << 7)) != 0;
    }

    public void setGroupIcon(boolean can) {
        this.value |= (can ? 1 : 0) << 8;
    }

    public boolean canSetGroupIcon() {
        return (this.value & (1 << 8)) != 0;
    }

    public void setGroupAdmin(boolean can) {
        this.value |= (can ? 1 : 0) << 9;
    }

    public boolean canSetGroupAdmin() {
        return (this.value & (1 << 9)) != 0;
    }
}
